Skip to content

Rust: Make path resolution tests work with Rust 1.96 and fix m::{self} when m is a trait - #22517

Open
paldepind wants to merge 3 commits into
mainfrom
rust/path-resolution-toolchain
Open

Rust: Make path resolution tests work with Rust 1.96 and fix m::{self} when m is a trait#22517
paldepind wants to merge 3 commits into
mainfrom
rust/path-resolution-toolchain

Conversation

@paldepind

Copy link
Copy Markdown
Contributor

Since v1.96, Rust gives a compiler error for m::{self} imports when m resolves to a struct. The qualifier must resolve to a module, trait, or enum which has been made clear in the reference.

We currently have a path resolution test that makes use of this and with 1.96+ this test is rejected by the compiler. This blocks what I'm trying to do over in #22493 with using a fixed Rust toolchain picked by the extractor.

This PR:

  • Updates the path-resolution tests to cover all three valid cases and moves the invalid struct case to the invalid directory.
  • The above revealed that we don't handle m::{self} when m is a trait correctly. That is fixed by this PR.

The invalid struct case still records a spurious result. Its inner self resolves to the enclosing module because of the else branch for "self" in getASuccessor. Fixing that would be less trivial, and this PR is still a net improvement: before we had a spurious result for valid code and now we only have a spurious result for invalid code.

@github-actions github-actions Bot added the Rust Pull requests that update Rust code label Sep 7, 2026
@paldepind
paldepind marked this pull request as ready for review September 7, 2026 09:05
Copilot AI balanced review requested due to automatic review settings September 7, 2026 09:05
@paldepind
paldepind requested a review from a team as a code owner September 7, 2026 09:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation matches Rust 1.96 semantics and includes focused valid and invalid regression coverage.

Review tier: Balanced
Findings: None

What changed in this PR

Updates Rust path resolution for Rust 1.96 compatibility and correctly handles {self} imports from traits.

Changes:

  • Supports {self} imports for modules, traits, and enums.
  • Moves the invalid struct case into invalid-code tests.
  • Updates expected path-resolution results.
File Description
PathResolution.qll Resolves trait {self} imports correctly.
main.rs Tests all valid qualifier types.
invalid/​main.rs Tests the rejected struct qualifier.
path-resolution.expected Updates generated expectations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@hvitved hvitved left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; I have started a DCA run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants